<?php

  	define('BASE_ROOT_PATH', dirname(dirname(__FILE__)));
	include_once( BASE_ROOT_PATH . "/word/db/DBMySQL.php");  

	$version= $_REQUEST['v'];
	if(empty($version)) {
	 	$msg = json_encode("版本号为空");
		echo '{"code":"1","msg":'.$msg.'}';
		exit();
	}
	$db = new DBMySQL();
	$rs = $db->Query("select version,appurl,introduce from t_version");
	if(empty($rs)) {
	  $msg = json_encode("获取版本号失败！");
		echo '{"code":"1","msg":'.$msg.'}';	  
		exit();	  
	}
	$val = $rs[0];
	$curVersion = $val['version'];
	$curVersion=floatval($curVersion);
	$url = $val['appurl'];
	$introduce = $val['introduce'];
	
	if($version < $curVersion)
	{
	
	  $data=array();
	  $data['url']=$url;
	  $data['version']=$curVersion;
	  $data['content']=$introduce;
      $dataStr = json_encode($data);
	  echo '{"code":"0","msg":"","data":'.$dataStr.'}';
	}else
	{
	  echo '{"code":"1","msg":"已经是最新版本了"}';
	}
	
?>